package com.system.healthproject.utils;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
    //获取当前系统时间 转换成数据库datetime类型
    public static Timestamp getDate(){
        Date date = new Date();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        String dateTime = df.format(date); // Formats a Date into a date/time string.
        System.out.println(dateTime);  // 2017-09-24 23:33:20

//      二、Date转换为Datetime
        long longTime = date.getTime();
        Timestamp timestamp = new Timestamp(longTime);
        return  timestamp;
    }

}
